/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved.
 * Description: reduce fusion header file
 * Author: liuhui
 * Create: 2020-10-15
 */

#ifndef HCOM_REDUCE_FUSION_H
#define HCOM_REDUCE_FUSION_H

#include "hccl/base.h"
#include <hccl/hccl_types.h>
#include "hcom_op_utils.h"
#include "op_fusion_base_pub.h"
#include "common/optimizer/graph_optimizer.h"
#include "common/optimizer/graph_optimizer_types.h"
#include "graph/compute_graph.h"

namespace hccl {

class HcomReduceFusion : public OpFusionBase {
public:
    HcomReduceFusion();
    ~HcomReduceFusion() override;
    HcclResult Run(ge::ComputeGraph& graph) override;
private:
    HcclResult GetFusionOps(ge::ComputeGraph& graph, FusionInfos& fusionOps);
    HcclResult GetFusionOpInfo(ge::NodePtr& nodePtr, FusionInfos& fusionOps);
    HcclResult GetFusionOption(const ge::NodePtr& nodePtr, FusionOption &fusionOption);
    HcclResult FuseOps(ge::ComputeGraph& graph, FusionSection& fusionSection);
    HcclResult GenerateFusionLabel(const FusionOption &fusionOption, std::string &fusionLabel);
    HcclResult GetFusionRootAndLabel(const ge::NodePtr& nodePtr, FusionOption &fusionOption);
    HcclResult GetFusionOpsSlices(FusionInfos& fusionInfos, FusionInfos& fusionInfosTemp);
};
}
#endif
